package character.inventory;

import data.EditorObject;

public class InventoryStrategy extends EditorObject {

	/**
	 * Describes who can possess inventories.
	 */
	public static enum InventoryOwner {
		/* An inventory exists that all characters in the party can access. */
		PARTY,
		/* An inventory exists for each character to privately use. */
		CHARACTER
	}

	/**
	 * Describes the display orientation of spatial inventories.
	 */
	public static enum InventoryOrientation {
		/* Rows are added at the bottom to expand the inventory. */
		VERTICAL,
		/* Columns are added to the right to expand the inventory. */
		HORIZONTAL
	}

	/**
	 * Describes the type of inventory being used.
	 */
	public static enum InventoryTypeStrategy {
		/* Inventories are weight based and each item takes up a certain weight. */
		WEIGHT,
		/*
		 * Inventories are spatially based and each item takes up a certain
		 * physical area.
		 */
		SPACE
	}

	/**
	 * Describes how the size of the inventory is to be determined.
	 */
	public static enum InventorySizeStrategy {
		/* Inventory size always the same regardless of statistics. */
		CONSTANT,
		/*
		 * Inventory size is based on a constant multiplied by a character
		 * point. For party inventory, the default value of the character point
		 * is used.
		 */
		LINEAR,
		/*
		 * Inventory size is based on a character point to the power of a
		 * constant. For party inventory, the default value of the character
		 * point is used.
		 */
		EXPONENTIAL
	}

	// Instance attributes
	private String title, character_point_name, weight_unit_name;
	private Boolean party_inventory, character_inventory;
	private InventoryTypeStrategy type;
	private InventorySizeStrategy size;
	private InventoryOrientation orientation;
	private Integer size_of_spatial_inventory, constant_size;
	private Float linear_multiplier, exponential_multiplier;

	/**
	 * Default constructor.
	 */
	public InventoryStrategy() {
		super();
	}

	/**
	 * Initializes all inventory strategy properties to defaults.
	 */
	@Override
	protected void initDefaultData() {
		defaults.put("title", "Inventory");
		defaults.put("party_inventory", Boolean.TRUE);
		defaults.put("character_inventory", Boolean.FALSE);
		defaults.put("type", InventoryTypeStrategy.WEIGHT);
		defaults.put("size", InventorySizeStrategy.LINEAR);
		defaults.put("weight_unit_name", "lbs");
		defaults.put("orientation", InventoryOrientation.HORIZONTAL);
		defaults.put("size_of_spatial_inventory", 5);
		defaults.put("constant_size", 50);
		defaults.put("character_point_name", "Strength");
		defaults.put("linear_multiplier", 5.0);
		defaults.put("exponential_multiplier", 1.5);
	}

	@Override
	public void init() {

	}

	// /**
	// * @deprecated
	// *
	// * Loads the inventory properties file and stores them as a class
	// variable.
	// */
	// public static void loadProperties() {
	// try {
	// Properties defaultProps = new Properties();
	// FileInputStream fis = new FileInputStream(new File(
	// Paths.propertiesPath
	// + File.separator
	// + "default_inventory.properties"));
	// defaultProps = new Properties();
	// defaultProps.load(fis);
	// fis = new FileInputStream(new File(Paths.propertiesPath
	// + File.separator
	// + "inventory.properties"));
	// properties = new Properties(defaultProps);
	// properties.load(fis);
	// } catch (FileNotFoundException e) {
	// Core.getInstance().logMessage(InventoryStrategy.class.getName(),
	// "Could not find inventory properties file.", e);
	// } catch (IOException e) {
	// Core.getInstance().logMessage(InventoryStrategy.class.getName(),
	// "Error loading inventory properties file.", e);
	// }
	// }
	//
	// /**
	// * @deprecated
	// *
	// * Saves any changes made to the inventory properties object.
	// */
	// public static void saveProperties() {
	// try {
	// File inventoryPropsFile = new File(Paths.propertiesPath
	// + File.separator
	// + "inventory.properties");
	// if (!inventoryPropsFile.exists()) {
	// inventoryPropsFile.createNewFile();
	// }
	// FileOutputStream fos = new FileOutputStream(inventoryPropsFile);
	// properties.store(fos, "Saved inventory properties.");
	// fos.close();
	// } catch (FileNotFoundException e) {
	// Core.getInstance().logMessage(InventoryStrategy.class.getName(),
	// "Could not find inventory properties file.", e);
	// } catch (IOException e) {
	// Core.getInstance().logMessage(InventoryStrategy.class.getName(),
	// "Error saving inventory properties file.", e);
	// }
	// }

	//	

	// // The properties that define how all inventory objects work
	// private static Properties properties;

}
